package com.xxzuibang.day8.方法的重载;

public class Test02 {
    public static void main(String[] args) {
        Student student=new Student();
        System.out.println(student.sum("小红", 20, 30));
        System.out.println(student.sum("小红", 20, 30, 40));
        System.out.println(student.sum("小红", 20, 30, 40, 50, 60));

    }
}
class Student{
 /*   public  String  student(String name,double s1,double s2){
        return name+s1+s2;
    }
    public  String  student(String name,double s1,double s2,double s3){
        return name+s1+s2+s3;
    }
    public  String  student(String name,double s1,double s2,double s3,double s4,double s5){
        return name+s1+s2+s3+s4+s5;
    }*/

    public  String sum(String name, int ...nums){
        int res=0;
        for (int i = 0; i < nums.length; i++) {
            res+=nums[i];
        }
        return name+res;
    }
}
